Skip to content

Improve queue performance with optimized slice operations#66

Merged
ren0503 merged 3 commits intomasterfrom
copilot/improve-repo-performance
Jan 16, 2026
Merged

Improve queue performance with optimized slice operations#66
ren0503 merged 3 commits intomasterfrom
copilot/improve-repo-performance

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Performance improvements targeting slice allocation patterns and memory efficiency in queue operations.

Changes

  • Slice insertion in AddJob: Replace double-append pattern with copy-based insertion

    // Before: O(n) extra allocation
    q.jobs = append(q.jobs[:idx], append([]Job{*job}, q.jobs[idx:]...)...)
    
    // After: In-place shift
    q.jobs = append(q.jobs, Job{})
    copy(q.jobs[idx+1:], q.jobs[idx:])
    q.jobs[idx] = *job
  • Pre-allocate slices in Run() and Retry() with estimated capacity instead of growing dynamically

  • Reuse slice capacity when clearing: execJobs = execJobs[:0] vs execJobs = []*Job{}

  • Remove unnecessary allocation: Don't initialize Stacktrace to empty slice; nil is idiomatic

  • Add benchmarks for key operations

Benchmark Results

Operation Before After Improvement
Slice insertion 7.1μs, 40KB, 2 allocs 5.7μs, 32KB, 1 alloc 20% faster
Preallocated slice 5.4μs, 108 allocs 4.8μs, 100 allocs 11% faster

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • vuln.go.dev
    • Triggering command: /tmp/go-build943415157/b001/exe/govulncheck /tmp/go-build943415157/b001/exe/govulncheck ./... --threads=4 --no-sublanguage-file-coverage --no-calculate-baseline --overwrite --language go --build-mode autobuild --source-root /home/REDACTED/work/queue/queue -p x64/src/net -trimpath ux_amd64/vet -I /tmp/go-build12221.0.8+9-LTS -I ux_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

check and improve performance for this repo


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: Ren0503 <54244073+Ren0503@users.noreply.github.com>
Copilot AI changed the title [WIP] Check and improve performance for the repository Improve queue performance with optimized slice operations Jan 16, 2026
Copilot AI requested a review from ren0503 January 16, 2026 16:50
- Append failed reason to stacktrace in HandlerError method
- Improves error debugging by maintaining error history
@ren0503 ren0503 marked this pull request as ready for review January 16, 2026 17:02
@ren0503 ren0503 merged commit f713235 into master Jan 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants